home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
By the Book
/
Learn C++ (CodeWarrior)
/
Chap 08.02 - stateBits
/
stateBits.cp
< prev
next >
Wrap
Text File
|
1995-10-21
|
559b
|
40 lines
#include <iostream.h>
int main()
{
char done = false;
char c;
short number;
while ( ! done )
{
cout << "Type a number: ";
cin >> number;
if ( cin.good() )
{
if ( number == 0 )
{
cout << "Goodbye...";
done = true;
}
else
cout << "Your number is: " << number << "\n\n";
}
else if ( cin.fail() )
{
cin.clear();
cin.get( c );
cout << c << " is not a number...";
cout << "Type 0 to exit\n\n";
}
else if ( cin.bad() )
{
cout << "\nYikes!!! Gotta go...";
done = true;
}
}
return 0;
}